package com.nginx.web.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nginx.web.domain.ConfFileQo;
import com.nginx.web.entity.ConfFile;
import com.nginx.web.service.impl.ConfFileServiceImpl;
import com.nginx.web.service.impl.ConfigServiceImpl;
import com.nginx.web.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Api(tags = "nginx文件")
@RequestMapping("/confFile")
@RestController
public class ConfFileController {

    @Autowired
    private ConfFileServiceImpl confFileService;

    @PostMapping("/listConfFile")
    @ApiOperation(value="查询nginx文件")
    public Result listConfFile(ConfFileQo confFileQo){
        Page<ConfFile> page = confFileService.listConfFile(confFileQo);
        return Result.success(page);
    }

    @PostMapping("/updateConfFile")
    @ApiOperation(value="修改nginx文件")
    public Result updateConfFile(ConfFile confFile){
        confFileService.updateConfFile(confFile);
        return Result.success();
    }

    @PostMapping("/readeConfFile")
    @ApiOperation(value="读取nginx文件")
    public Result readeConfFile( ){
        confFileService.readeConfFile();
        return Result.success();
    }

    @PostMapping("/writeConfFile")
    @ApiOperation(value="写入nginx文件")
    public Result writeConfFile( ){
        confFileService.writeConfFile();
        return Result.success();
    }

    @PostMapping("/startNginx")
    @ApiOperation(value="startNginx")
    public Result startNginx( ){
        String str = confFileService.startNginx();
        return Result.success(str);
    }

    @PostMapping("/reloadNginx")
    @ApiOperation(value="reloadNginx")
    public Result reloadNginx( ){
        String str = confFileService.reloadNginx();
        return Result.success(str);
    }

    @PostMapping("/checkNginx")
    @ApiOperation(value="checkNginx")
    public Result checkNginx( ){
        String str = confFileService.checkNginx();
        return Result.success(str);
    }

}
